package Exceptions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class ExceptionDemo {

//	public static void main(String[] args) {
//		Students students = new Students(1, "张三", 10000.0);
//		String name = students.getName();
//		students = null;
//		String name2 = students.getName();
//	}
	
	public static void main(String[] args) {
		//运行时异常，程序运行时才出现的异常
		//java.lang.ArithmeticException: / by zero
		int i = 1;
		System.out.println(23 / i);
		//编译时异常，在写代码时就需要处理这个异常，不然会一直报错
		//Unhandled exception type InterruptedException
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		//编译时异常，类似于未雨绸缪，认为这个文件因为硬盘坏了或不小心删除找不到了
		try {
			FileInputStream fileInputStream = new FileInputStream(new File(""));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
}
